﻿//-----------------------------------------------------------------------
//
// NAME:        BallClaimPacket.cs
//
// PROJECT:     Battle Core Protocol Library
//
// COMPILER:    Microsoft Visual Studio .NET 2005
//
// DESCRIPTION: Player Death Packet implementation.
//
// NOTES:       None.
//
// $History: BallClaimPacket.cs $
//
//-----------------------------------------------------------------------

// Namespace usage
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using BattleCore.Events;

// Namespace declaration
namespace BattleCore.Protocol
{
    /// <summary>
    /// BallClaimPacket object.  This packet is sent to the server by a
    /// Player who has grabbed the ball.
    /// </summary>
    internal class BallClaimPacket : IPacket
    {
        /// <summary>Ball Claim Packet Event Data</summary>
        private BallClaimEvent m_event = new BallClaimEvent();

        ///<summary>Reliable Packet Property</summary>
        public Boolean Reliable { get { return false; } }

        /// <summary>
        /// Ball Claim Event Property
        /// </summary>
        public BallClaimEvent Event
        {
            set { m_event = value; }
            get { return m_event; }
        }

        /// <summary>
        /// Packet Data Property
        /// </summary>
        public Byte[] Packet
        {
            set
            {
                // Never going to receive this packet from the server
            }
            get
            {
                // Create the packet memory stream
                MemoryStream packet = new MemoryStream(6);

                // Write the packet data to the memory stream
                packet.WriteByte(0x1F);
                packet.WriteByte(m_event.BallId);
                packet.Write(BitConverter.GetBytes((UInt32)(Environment.TickCount / 10)), 0, 4);

                // return the packet data
                return packet.GetBuffer(); ;
            }
        }
    }
}
